<%@ page import="java.sql.Statement" import="java.sql.ResultSet" import="java.sql.Connection" import="java.sql.DriverManager"%>
<%@page import="connection.DBConnection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Credit Periodic Report</title>
</head>
<body>
<h2 align="center"> Credit Periodic Report </h2>
<form>

  <%
        String exportToExcel = request.getParameter("exportToExcel");
        if (exportToExcel != null && exportToExcel.toString().equalsIgnoreCase("YES")) 
        {
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition", "inline; filename=" + "CreditPeriodicRegister.xls");
 
        }
    %>

<table border=1 align="center"> 
<tr>
	<th>Invoice Number</th>
	<th>Date</th>
	<th>Customer Name</th>
	<th>Customer Code</th>
	<th>Product Name</th>
	<th>Product Quantity</th>
	<th>Product Rate</th>
	<th>Net Amount</th>
	<th>Taxation Category</th>
	<th>Tax Amount</th>
	<th>Transport Charges</th>
	<th>Total Amount</th>
	<th>Rejection Reason </th>
	<th>Credit Limit</th>
</tr>
<%
        String dte=(String) request.getAttribute("frmdte");
		 String dte1=(String) request.getAttribute("todte");
			
			try
			{
				String qry;
	            Class.forName("com.mysql.jdbc.Driver");
	            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/boa","root","root");
	            Statement s = con.createStatement();                
	            qry=" Select * from CreditNote where CAST(date as DATE) between '"+dte+"' and '"+dte1+"';";
	            ResultSet rs=s.executeQuery(qry);
       		  while(rs.next()){ %>
<tr>
            		<td><%= rs.getString(1)%></td>
            		<td><%= rs.getString(2)%></td>
            		<td><%= rs.getString(3)%></td>
            		<td><%= rs.getString(4)%></td>
            		<td><%= rs.getString(5)%></td>
 					<td><%= rs.getDouble(6)%></td>
 					<td><%= rs.getDouble(7)%></td>           		
            		<td><%= rs.getDouble(8)%></td>
            		<td><%= rs.getDouble(9)%></td>
            		<td><%= rs.getDouble(10)%></td>
            		<td><%= rs.getDouble(11)%></td>
            		<td><%= rs.getDouble(12)%></td>
            		<td><%= rs.getString(13)%></td>
            		<td><%= rs.getInt(14)%></td>
            		
</tr>
        		<% } %>
  
	 		<% }
			catch(Exception e){} %>
						
</table>
<br><br> 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
        if (exportToExcel == null) {
    %>
    <a href="CreditPeriodicReport.jsp?exportToExcel=YES">Export to Excel</a>
    <%
        }
    %>
</form>

</body>
</html>